package com.hkpickup.jdo;
import java.util.List;

import javax.jdo.JDOObjectNotFoundException;
import javax.jdo.PersistenceManager;
import javax.jdo.Query;

import com.google.appengine.demos.jdoexamples.PMF;

public class WebSiteUtils {
	  public static void insert(String url, boolean watching) {
		  WebSiteEntry entry = new WebSiteEntry(url, watching);
		    PersistenceManager pm = PMF.get().getPersistenceManager();
		    pm.makePersistent(entry);
		  }
	  
	  public static List<WebSiteEntry> getEntries() {
		    PersistenceManager pm = PMF.get().getPersistenceManager();
		    Query query = pm.newQuery(WebSiteEntry.class);
		    query.setOrdering("lastUpdate DESC");
		    List<WebSiteEntry> entries = (List<WebSiteEntry>) query.execute();
		    return entries;
		  }
}
